import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CertificatesVO, CertificatesForm, CertificatesQuery } from '@/api/canteen/certificates/types';

/**
 * 查询证书管理列表
 * @param query
 * @returns {*}
 */

export const listCertificates = (query?: CertificatesQuery): AxiosPromise<CertificatesVO[]> => {
  return request({
    url: '/canteen/certificates/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询证书管理详细
 * @param certificatesId
 */
export const getCertificates = (certificatesId: string | number): AxiosPromise<CertificatesVO> => {
  return request({
    url: '/canteen/certificates/' + certificatesId,
    method: 'get'
  });
};

/**
 * 新增证书管理
 * @param data
 */
export const addCertificates = (data: CertificatesForm) => {
  return request({
    url: '/canteen/certificates',
    method: 'post',
    data: data
  });
};

/**
 * 修改证书管理
 * @param data
 */
export const updateCertificates = (data: CertificatesForm) => {
  return request({
    url: '/canteen/certificates',
    method: 'put',
    data: data
  });
};

/**
 * 删除证书管理
 * @param certificatesId
 */
export const delCertificates = (certificatesId: string | number | Array<string | number>) => {
  return request({
    url: '/canteen/certificates/' + certificatesId,
    method: 'delete'
  });
};
